define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'zzjump/index',
                    add_url: 'zzjump/add',
                    edit_url: 'zzjump/edit',
                    del_url: 'zzjump/del',
                    multi_url: 'zzjump/multi',
                    table: 'zzjump',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'page', title: __('Page')},
                        {field: 'qrcode', title: __('Qrcode')},
                        {field: 'id', title: __('Operate'), table: table, buttons: [
                            {
                                name: 'read',
                                text: __('Edit'),
                                title: __('Edit'),
                                icon: 'fa fa-edit',
                                classname: 'btn btn-xs btn-success btn-dialog', url: 'Hkstore/edit'},
                            {
                                name: 'del',
                                text: __('Del'),
                                title: __('Del'),
                                icon: 'fa fa-trash',
                                classname: 'btn btn-xs btn-ajax btn-danger btn-delone',
                                url: 'Hkstore/del',
                                confirm: '确定要执行该操作吗?'},
                            {
                                name: 'qrcode',
                                text:__('二维码生成'),
                                title:__('二维码生成'),
                                icon: 'fa fa-edit',
                                classname: 'btn btn-xs btn-info btn-dialog',
                                url:'Zzjump/qrcode'
                            }
                        ], events: Table.api.events.operate, formatter: Table.api.formatter.buttons,operate:false}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});